import Vue from "vue";
import App from "./app.vue";
import VueRouter from 'vue-router';
import CLivePay from "../../src/c-live-pay/index.js";
import {
  Tab,
  Tabs,
  Cell,
  Tag,
  Search,
  Toast,
  Popup,
  ActionSheet,
  PullRefresh,
  List,
  Field,
  Switch,
  Stepper,
  NavBar,
  Empty,
  RadioGroup,
  Radio,
  CellGroup,
  Form,
  DatetimePicker,
  Picker,
  Button,
  Sku,
  Overlay,
  Sticky,
  Skeleton,
  Icon
} from 'vant';

Vue.use(Sticky)
Vue.use(Overlay);
Vue.use(Tabs);
Vue.use(Tab);
Vue.use(Cell);
Vue.use(Tag);
Vue.use(Search);
Vue.use(Toast);
Vue.use(Popup);
Vue.use(ActionSheet);
Vue.use(PullRefresh);
Vue.use(List);
Vue.use(Icon);
Vue.use(Field);
Vue.use(Switch);
Vue.use(Stepper);
Vue.use(NavBar);
Vue.use(Empty);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(CellGroup);
Vue.use(Form);
Vue.use(DatetimePicker);
Vue.use(Picker);
Vue.use(Button);
Vue.use(Sku);
Vue.use(Skeleton);

Vue.use(VueRouter);
Vue.use(CLivePay)

const router = new VueRouter({});

import {xiaoeImage, loading} from '@xiaoe/goose'

Vue.use(xiaoeImage);
Vue.use(loading)

// head数据
var head = document.head;

// 新增图标库
let link = document.createElement('link');
link.rel = 'stylesheet';
link.href = '//at.alicdn.com/t/font_511353_tt2yjy5jho.css'
head.appendChild(link)

//<script src="//sdk.xiaoeknow.com/sensors_static/v33/h5/sensorsStatistics.js"></script>
let script = document.createElement('script');
script.src = "//sdk.xiaoeknow.com/sensors_static/v33/h5/sensorsStatistics.js";
head.appendChild(script)

// 字体根大小设置（屏幕宽度最大限制480px），用于rem单位
var htmlDom = document.documentElement;
var windowWidth = window.innerWidth || htmlDom.clientWidth;
var proportion = 7.5
if (windowWidth >= 480) {
  windowWidth = 480;
} else {
  proportion = 7.5;
}
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
htmlDom.style.fontSize = windowWidth / proportion + 'px';
(function () {
  document.addEventListener('DOMContentLoaded', function () {
    if (!htmlDom.style.fontSize) {
      var htmlDomProtect = document.documentElement;
      var windowWidth = htmlDomProtect.clientWidth;
      if (windowWidth >= 480) {
        windowWidth = 480;
      } else {
        proportion = 7.5;
      }
      htmlDomProtect.style.fontSize = windowWidth / proportion + 'px';
    }
  }, false);
})();

window.addEventListener(evt, function () {
  setTimeout(function () {
    var htmlDomProtect = document.documentElement;
    var windowWidth = htmlDomProtect.clientWidth;
    if (windowWidth >= 480) {
      windowWidth = 480;
    } else {
      proportion = 7.5;
    }
    htmlDomProtect.style.fontSize = windowWidth / proportion + 'px';
  }, 200);
}, false);

new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");
